package de.playmee.views;

import java.util.List;

import de.playmee.Channel;
import de.playmee.R;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SimpleSpinnerAdapter extends BaseAdapter {
	
	Context context;
	private List<Channel> channels;
	
	public SimpleSpinnerAdapter(Context context, List<Channel> channels) {
		this.context = context;
		this.channels = channels;
	}

	@Override
	public int getCount() {
		return channels.size();
	}

	@Override
	public Object getItem(int position) {
		return channels.get(position);
	}

	@Override
	public long getItemId(int position) {
		return channels.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return createTextView(position, 5, 20);
	}
	
	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		return createTextView(position, 20, 20);
	}
	
	
	private TextView createTextView(int position, int padding, float textSize) {
		TextView view = new TextView(context);
		view.setText(channels.get(position).getLabel());
		view.setTextSize(textSize);
		view.setTextColor(context.getResources().getColor(R.color.custom_theme_textcolor_inverse));
		view.setPadding(padding, padding, padding, padding);
		return view;
	}
}
